package com.zx.dsptuneup_cloud.Tools;

/**
 * @author tb
 * @date 2021/5/13 - 14:20
 */
public class TenValueToHexUtils {
    /**
     * 10进制转16进制并补零补成两位
     */
    public static String TenToHexAndAppendZeroTo2(Integer parameter){
        String dl = NumberBaseConversionUtil.valueTenToValueHex(parameter);
        if (dl.length() == 1) {
            dl = "0" + dl;
        }
        return dl;
    }

    /**
     * 10进制转16进制并补零补成四位
     */
    public static String TenToHexAndAppendZeroTo4(Integer parameter){
        String dl = NumberBaseConversionUtil.valueTenToValueHex(parameter);
        if (dl.length() == 1) {
            dl = "000" + dl;
        }else if (dl.length()==2){
            dl="00"+dl;
        }else if (dl.length()==3){
            dl="0"+dl;
        }
        return dl;
    }
    /**
     * 10进制转16进制并补零补成四位
     */
    public static String TenToHexAndAppendZeroTo8(Integer parameter){
        String dl = NumberBaseConversionUtil.valueTenToValueHex(parameter);
        if (dl.length() == 1) {
            dl = "0000000" + dl;
        }else if (dl.length()==2){
            dl="000000"+dl;
        }else if (dl.length()==3){
            dl="00000"+dl;
        }else if (dl.length()==4){
            dl="0000"+dl;
        }else if (dl.length()==5){
            dl="000"+dl;
        }else if (dl.length()==6){
            dl="00"+dl;
        }else if (dl.length()==7){
            dl="0"+dl;
        }
        return dl;
    }
    /**
     * @ClassName: valueTenToValueHex(10进制转16进制)
     * @Description: 自动补位，如000000ff，正数正常，负数首位补1
     * @date 2020年4月15日
     */
    public static String tenToHexAndAppendZeroTo4Sign(Integer valueTen){
        String dl = NumberBaseConversionUtil.tenToHexSign(valueTen);
        if (dl.length() == 1) {
            dl = "000" + dl;
        }else if (dl.length()==2){
            dl="00"+dl;
        }else if (dl.length()==3){
            dl="0"+dl;
        }
        return dl;
    }
    public static String TenToHexAndAppendZeroTo2(String parameter){
        String dl = NumberBaseConversionUtil.valueTenToValueHex(parameter);
        if (dl.length() == 1) {
            dl = "0" + dl;
        }
        return dl;
    }
}
